# coding:utf-8

lhz = {'鲁班': 100, '甄姬': 120, '妲己': 130}
print(lhz['鲁班'])
# KeyError
# print(lhz['王昭君'])

# 防止报错
# 如果不存在，返回None
print(lhz.get('甄姬'))
print(lhz.get('安其拉'))
# 防止返回None，可以指定要给默认值
print(lhz.get('赵云', 180))
print(lhz.get('妲己', 180))

# 新增
lhz['后羿'] = 145
print(lhz)

# 修改
lhz['后羿'] = 160
print(lhz)

# 遍历
for item in lhz.items():
    print(item)
print('+++++++++++')
for k, v in lhz.items():
    print(f'{k} >>> {v}')
print('+++++++++++')
for key in lhz.keys():
    print(f'{key} = {lhz.get(key)}')
print('+++++++++++')
for value in lhz.values():
    print(value)
